<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.12/vue.js"></script>
</head>
<body>
<div id="app">
    <input type="text" v-model="msg">
    <br>
    <input type="text" v-model="obj.name">
    <ul>
        <li v-for="value in obj" :key="value">{{value}}</li>
    </ul>
</div>
<script>
    Vue.config.productionTip = false
    const vm = new Vue({
        el: '#app',
        data() {
            return {
                msg:'Hello Vue',
              obj:{
                  name:'zhangsan',
                  age:18
              }
            }
        },
        watch:{
            //基本使用
            msg(){
                console.log('msg监听中...')
            },
            //监听对象中的值
            "obj.name"(newVal,oldVal){
                console.log('obj.name监听中...',newVal,oldVal)
            },
        //    深度监听+立即监听
            obj:{
                deep:true,
                immediate:true,
                handler(newVal,oldVal){
                    console.log('obj监听中...')
                    console.log(newVal,oldVal)
                }
            }
        }
    })
</script>
</body>
</html>